/**
 * Created with JetBrains WebStorm.
 * User: mumble
 * Date: 6/26/12
 * Time: 12:17 AM
 * To change this template use File | Settings | File Templates.
 */

function GameManager(service)
{
    this.service = service;
    this.gameConfProvider = this.service.useDbModel('GameConf').GameConf;
    this.gameArray = [];
    this.gameList = {};

}

GameManager.prototype = {
    init : function(err, cb)
    {
        var self = this;
        this.gameConfProvider.find(function(dbErr, gameList){
            if(err)
            {
                err = dbErr;
                return;
            }
            gameList.forEach(function(game){
                var key = game.game_key;
                self.gameList[key] = {
                    key : game.game_key,
                    game_name : game.game_name,
                    path : game.path,
                    min_user: game.min_user,
                    max_user : game.max_user


                };
            });
            self.gameArray = gameList;
            cb();

        })
    },
    getGameList : function(){
        return this.gameList;
    }
};
module.exports.GameManager = GameManager;